package com.ea.eadp.nexus.test.workflow.newconsole.parentemail;

import com.ea.eadp.nexus.test.workflow.WorkflowElement;
import com.ea.eadp.nexus.test.workflow.WorkflowElementArgument;
import com.ea.eadp.nexus.test.pageDefinition.newconsole.UpdateParentEmailPage;
import org.openqa.selenium.WebDriver;
import org.testng.Assert;

/**
 * Created with IntelliJ IDEA.
 * User: yjtao
 * Date: 1/8/15
 * Time: 11:36 AM
 * To change this template use File | Settings | File Templates.
 */
public class UpdateEmailWorkflowElement  extends WorkflowElement {
    protected UpdateParentEmailPage page;
    public boolean pass = true;
    public String expectedMessage = null;

    public UpdateEmailWorkflowElement(
            WebDriver driver, WorkflowElementArgument argument
    ) {
        super(driver, argument);
        page = new UpdateParentEmailPage(driver);
    }

    @Override
    public void init() {
        page.assertThisIsThePage();
    }

    @Override
    public void doAction() {
        page.enterNewEmailAddress(args.parentEmail);
    }

    @Override
    public void doVerification() {
        if(!pass){
            page.clickUpdateButton();

            String message = page.getStatusMessage();
            Assert.assertEquals(message, expectedMessage, "message");
        }
    }
    @Override
    public void moveNext() {
        page.clickUpdateButton();
    }
}